const mongoose = require('mongoose');
const { Schema } = mongoose;
const baseModel = require('./baseModel')
const md5 = require('../util/crypto')

const userSchema = new Schema({
    name:{
        type:String,
        required:true
    },
    //此处传入的要进行crypt加密
    password:{
        type:String,
        required:true,
        //查询的时候不返回这个值
        select: false,
        set:(value)=>md5(value)
    },
    email:{
        type:String,
        required:true
    },
    phone:{
        type:String,
        required:true
    },
    //头像信息
    image:{
        type:String,
        required:false
    },
    //频道的封面
    cover:{
        type:String,
        required:false
    },
    //频道描述
    channeldes:{
        type:String,
        required:false
    },
    //被关注的数量
    subscribecount:{
        type:Number,
        default:0,
        required:false
    },
    ...baseModel
});

module.exports =userSchema